from __future__ import division

import math

import pygame

from vectors import Vector
from collision import Rect

from objects import Object

class Command(Object):
	graphic = "objects/command.png"
	
	render_layer = 1
	collisions = None
	
	def __init__(self, level, position, angle=0):
		super(Command, self).__init__(position)
		
		self.position = Vector(*position)
		self.angle = angle
		
		x, y = self.position
		self.rect = Rect((x - 16, y - 16, 64, 64))
		self.circle = self.rect.circle()
		
		self.health = 1
		
		self._remove = False
	
	def update(self):
		pass
	
	def draw(self, surface):
		x, y = self.position
		
		if self.health > 0:
			rotate = pygame.transform.rotozoom(self.graphic, math.degrees(-self.angle), 1)
			width, height = rotate.get_size()
			surface.blit(self.graphic, (x - width // 2, y - height // 2))
			
			pygame.draw.rect(surface, (0, 255, 0), Rect(x - 10, y + 8, int(20 * self.health), 3))
	
from graphics import graphics, request_replace
request_replace(Command)
